#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
#include <vector>
int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    int earn = 0;
    int buy = v[0];
    for (int i = 0; i < n; i++)
    {
        earn = max(v[i] - buy, earn);
        if (v[i] < buy)
            buy = v[i];
    }
    cout << earn;
    return 0;
}

#include <iostream>
using namespace std;
#include <vector>
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(n + 2, vector<int>(m + 2, 0));
    n++;
    m++;
    v[1][1] = 1;
    int x, y;
    cin >> x >> y;
    x++;
    y++;
    v[x][y] = -1;
    vector<vector<int>> dx = { {1,-1},{2,-2} };
    vector<vector<int>> dy = { {2,-2},{1,-1} };
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            int x1 = x + dx[i][j];
            for (int k = 0; k < 2; k++)
            {
                int y1 = y + dy[i][k];
                if (x1 >= 1 && x1 <= n && y1 >= 1 && y1 <= m)
                {
                    //cout<<x1<<" "<<y1<<endl;
                    v[x1][y1] = -1;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        //cout<<i<<endl;
        for (int j = 1; j <= m; j++)
        {
            if (v[i][j] != -1)
            {
                if (v[i - 1][j] != -1)
                    v[i][j] += v[i - 1][j];
                if (v[i][j - 1] != -1)
                    v[i][j] += v[i][j - 1];
                // cout<<v[i][j]<<" ";
            }

        }
        //cout<<endl;
    }
    cout << v[n][m] << endl;
    return 0;
}